import { credit } from "../../../../js/modules/credit.js";
import { forms, storage, util, dialog } from '../../../../js/util';
import authorize from '../../../../js/modules/authorize.js'
import BasePage from '../../../../js/common/base-page'
BasePage({
  pageKey:"billDetailItem",

  /**
   * 页面的初始数据
   */
  data: {
    page: {
      PageIndex: 1,
      PageSize: 20,
      keywords: "",
      // sortField: "Id",
      // sortDirect: "desc"
    },
    list: [],
    hasMoreData: true,
    typeId:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.id == null) {
      util.alert("请求无效");
      return;
    }
    var that = this;
    that.setData({
      billId: options.id,
      typeId:options.type,
      accountId: options.accountId
    });
    that.loadList();
  },
  /**
     * 加载列表
     *  */
  loadList() {
    var that = this;
    var page = this.data.page;
    credit.get_bill_order_list(page, that.data.accountId, that.data.billId, that.data.typeId, function (content) {
      var hasMoreData = content.count > (page.PageIndex) * page.PageSize;
      var index = that.data.list.length;
      var data = content.data;
      //当分页大于1时，累加
      if (page.PageIndex > 1) {
        data = that.data.list.concat(data);
      }
      //如果key为变量作为key值的时候要用[]包裹起来
      that.setData({
        list: data,
        hasMoreData: hasMoreData,
        isLoadComplete: true
      });
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})